package com.hotelvp.tonight.prefs;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class BasePrefs
{
  private SharedPreferences.Editor editor;
  private SharedPreferences prefs;

  protected BasePrefs(Context paramContext, String paramString)
  {
    this.prefs = paramContext.getSharedPreferences(paramString, 0);
  }

  private void ensureEditorAvailability()
  {
    if (this.editor == null)
      this.editor = this.prefs.edit();
  }

  protected boolean getBoolean(String paramString, boolean paramBoolean)
  {
    return this.prefs.getBoolean(paramString, paramBoolean);
  }

  protected float getFloat(String paramString, float paramFloat)
  {
    return this.prefs.getFloat(paramString, paramFloat);
  }

  protected int getInt(String paramString, int paramInt)
  {
    return this.prefs.getInt(paramString, paramInt);
  }

  protected long getLong(String paramString, long paramLong)
  {
    return this.prefs.getLong(paramString, paramLong);
  }

  protected String getString(String paramString1, String paramString2)
  {
    return this.prefs.getString(paramString1, paramString2);
  }

  protected void putBoolean(String paramString, boolean paramBoolean)
  {
    ensureEditorAvailability();
    this.editor.putBoolean(paramString, paramBoolean);
  }

  protected void putFloat(String paramString, float paramFloat)
  {
    ensureEditorAvailability();
    this.editor.putFloat(paramString, paramFloat);
  }

  protected void putInt(String paramString, int paramInt)
  {
    ensureEditorAvailability();
    this.editor.putInt(paramString, paramInt);
  }

  protected void putLong(String paramString, long paramLong)
  {
    ensureEditorAvailability();
    this.editor.putLong(paramString, paramLong);
  }

  protected void putString(String paramString1, String paramString2)
  {
    ensureEditorAvailability();
    this.editor.putString(paramString1, paramString2);
  }

  public void save()
  {
    if (this.editor != null)
      this.editor.commit();
  }
}